package fr.univ.lille1.server.daoimpl;

import java.util.List;

import javax.ejb.Stateless;

import fr.univ.lille1.server.dao.UserDao;
import fr.univ.lille1.server.domain.User;

@Stateless
public class UserDaoImpl extends DaoImpl<Integer, User> implements UserDao {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3432511272456888396L;

	public User findByName(String name) {
		List<User> list = list("SELECT u from User u WHERE u.name = ?1",name);
		if(list == null || list.size()==0){
			return null;
		}
		return list.get(0);
	}

	public User findByMail(String mail) {
		List<User> list = list("SELECT u from User u WHERE u.mail = ?1",mail);
		if(list == null || list.size()==0){
			return null;
		}
		return list.get(0);
	}

}
